<?php
class Policko {
	
	private $radek;
	private $sloupec;
	private $oblast;
	private $id;
	public $cislo = null;
	private $moznosti = array(1,2,3,4,5,6,7,8,9);
	private $volno = true;
	
	function __construct($radek, $sloupec, $id) {
		$this->setRadek($radek);
		$this->setSloupec($sloupec);
		$this->setId($id);
		$this->setOblastById();
	}
	
	
	function getStav() {
		return $this->volno;
	}
	
	function getRadek() {
		return $this->radek;
	}
	
	function getSloupec() {
		return $this->sloupec;
	}
	
	function getOblast() {
		return $this->oblast;
	}
	
	function getId() {
		return $this->id;
	}
	
	function setRadek($id) {
		$this->radek=$id;
	}
	
	function setSloupec($id) {
		$this->sloupec=$id;
	}
	
	function setOblast($id) {
		$this->oblast=$id;
	}
	
	function setId($id) {
		$this->id=$id;
	}
	
	function getCislo() {
		return $this->cislo;
		
	}
	
	function setCislo($cislo) {
		if(in_array($cislo, array(1,2,3,4,5,6,7,8,9))){
			$this->cislo=$cislo;
			$this->volno = false;
		}
	}
	
	function setMoznosti($moznosti) {
		if ($this->volno){
			$this->moznosti = array_intersect($this->moznosti, $moznosti);
		}
	}
	
	function getMoznosti() {
		return $this->moznosti;
	}
	
	/*
	 * Podle Id políčka nastaví oblast, ve kterém políčko je
	 */
	function setOblastById() {
		if (in_array($this->id, array(1,2,3,10,11,12,19,20,21))) {
			$this->setOblast(1);
		}elseif (in_array($this->id, array(4,5,6,13,14,15,22,23,24))){
			$this->setOblast(2);
		}elseif (in_array($this->id, array(7,8,9,16,17,18,25,26,27))){
			$this->setOblast(3);
		}elseif (in_array($this->id, array(28,29,30,37,38,39,46,47,48))){
			$this->setOblast(4);
		}elseif (in_array($this->id, array(31,32,33,40,41,42,49,50,51))){
			$this->setOblast(5);
		}elseif (in_array($this->id, array(34,35,36,43,44,45,52,53,54))){
			$this->setOblast(6);
		}elseif (in_array($this->id, array(55,56,57,64,65,66,73,74,75))){
			$this->setOblast(7);
		}elseif (in_array($this->id, array(58,59,60,67,68,69,76,77,78))){
			$this->setOblast(8);
		}elseif (in_array($this->id, array(61,62,63,70,71,72,79,80,81))){
			$this->setOblast(9);
		}
	}
}
?>